package com.hzdl.car.sqlprovider;

import com.hzdl.car.util.Common;
import com.hzdl.car.vo.RentVo;
import org.apache.ibatis.jdbc.SQL;

public class RentSqlProvider {
    public String findRent(RentVo rentVo){
        return new SQL(){{
            SELECT("*");
            FROM("bus_rent");
            if(!Common.isEmpty(rentVo.getIdentity())){
                WHERE("identity like concat('%',#{identity},'%')");
            }
            if(!Common.isEmpty(rentVo.getRentId())){
                WHERE("rentId like concat('%',#{rentId},'%')");
            }
            if(rentVo.getBeginDate()!=null){
                WHERE("beginDate >= #{beginDate}");
            }
            if(rentVo.getReturnDate()!=null){
                WHERE("returnDate >= #{returnDate}");
            }
            if(rentVo.getRentFlag()!=null){
                WHERE("rentFlag = #{rentFlag}");
            }


        }}.toString();
    }
}
